home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / i / internet / software / netstsr / udp.h < prev   
Encoding:
C/C++ Source or Header  |  1992-06-15  |  1.8 KB  |  56 lines

  1. #ifndef _INET_UDP
  2. #define _INET_UDP
  3.  
  4. #ifndef _INET_IP
  5. #include "ip.h"
  6. #endif
  7.  
  8. #ifndef _INET_ICUST
  9. #include "inetcust.h"
  10. #endif
  11.  
  12.  
  13.  
  14. typedef struct _udp
  15. {    unsigned src_port;            /* source port */    unsigned dst_port;            /* dest port */    unsigned length;            /* length of UDP packet incl. header */    unsigned chksum;            /* UDP checksum */} UDP;
  16.  
  17. #ifndef __TCP_PSEUDO
  18. #define __TCP_PSEUDO
  19.  
  20. typedef struct                 /* tcp pseudoheader */
  21. {
  22.     INADDR    src;            /* source internet addr */
  23.     INADDR    dst;            /* destination internet addr */
  24.     u_short    protocol;        /* used protocol (hibyte must be zero!!) */
  25.     u_short    length;            /* length of tcp header + tcp data */
  26. } TCP_PSEUDO;
  27.  
  28. #endif
  29.  
  30. typedef int (*UDP_UPCALL)(int, char *, int);
  31. /* The UDP Connection structure */typedef struct udp_ctl
  32. {    struct udp_ctl *next;        /* link to next udp port */
  33.     u_short        handle;            /* handle of this port */    u_short        lcl_port;        /* local port */    u_short        fgn_port;        /* foreign port */    INADDR        fhost;            /* foreign host */    UDP_UPCALL    upcall;            /* incoming packet handler */
  34.     u_short        udp_err;        /* send error */    u_short        data_len;        /* length of data */
  35.     char        *data;            /* data */
  36.     PACKET       *pkt;
  37.     TIMER        udp_tm;            /* timer how long to keep packet */} UDP_CTL;
  38.  
  39. #define UDP_KEEPPKT        400            /* 2 sec */
  40. #define UDP_MAXPORTS    4
  41.  
  42. #define UDP_OK        0        /* no error */
  43. #define UDP_OVR        1        /* overrun */#define UDP_MISS    2        /* packet timer expired */
  44. #define UDP_NORECV    3        /* destination unreachable */
  45. #define UDP_CLOSED    4        /* closed port */
  46. #define udp_head(p_ip)    ((UDP *)(((char *)p_ip) + ip_hdrlen(p_ip)))#define udp_data(p_udp)    ((char *)(p_udp) + sizeof(UDP))
  47. int udp_init(void);
  48. int udp_exit(void);
  49.  
  50. int udp_open(u_short,UDP_UPCALL);
  51. int udp_close(u_short);
  52. int udp_write(u_short,char *,u_short,INADDR, u_short);
  53. int udp_free(u_short);
  54. UDP_CTL *udp_getctl(u_short);
  55. #endif
  56.